
<template>
  <div style="height:100%;overflow:hidden;">
    <div style="height:100%;">
      <div v-if="Options.showreportview == '1'" style="height:32px;">
        <div class="el-tabs el-tabs--top el-tabs--border-card" style="height:32px;">
          <div class="el-tabs__header is-top">
            <div class="el-tabs__nav-wrap is-top">
              <div ref="r_tab_1" :class="{ 'el-tabs__item is-top': true, 'is-active': showtabid == 1 }" @click="rTabclick(1)">
                项目结果</div>
              <div ref="r_tab_2" :class="{ 'el-tabs__item is-top': true, 'is-active': showtabid == 2 }" @click="rTabclick(2)">
                报告预览</div>
            </div>
          </div>
        </div>
      </div>
      <div v-show="Options.showreportview != '1' || showtabid == 1" style="height:100%;">
        <div :style="(Options.doubleresultcol > 0 ? 'width:50%;float:left;' : '') + 'height:' + SetResultHeight()">
          <vxe-table :data.sync="resultlist" @current-change="currentResultChangeEvent" :sort-config="{ trigger: 'cell' }"
            :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false, activeMethod: activeMethod, }"
            :mouse-config="{ selected: true }" :select-config="selectConfig" @cell-dblclick="DblEvent"
            @cell-click="ResultCellClick" @edit-actived="ResultActive" @edit-closed="ResultClose"
            :cell-class-name="ColumnClassName" :height="h" highlight-current-row ref="xTableResult" resizable border
            show-header-overflow="tooltip" show-overflow="tooltip" header-align="center" :show-xscroll="xscrollflag"
            :loading="loadingResult" size="mini" :width="w" config-record-key="ResultTable" :tableid="tableid"
            status-msg-group="none" class="ResultTable" @dblclick.native="handleEmptyDblclick">
            <vxe-table-column type="index" width="30px" v-if="Options['input_hideresultno'] == '0'"
              align="center"></vxe-table-column>
            <vxe-table-column :field="items.field" :title="items.title" :width="items.width"
              v-for="(items) in tableResultColumn" v-bind:key="items.field"
              :align="items.field == 'result_str' && Options.resultstralignmentright > 0 ? 'right' : 'left'"
              :edit-render="{ name: 'input', autoselect: true }" header-align="center">
              <template v-slot="{ row }"
                v-if="items.field == 'alertflag' || items.field == 'redo_flag' || items.field == 'modify_flag'">
                <div v-if="items.field == 'alertflag' && row.alertflag > 0"
                  v-bind:style="{ background: Options.alertflagcolor ? Options.alertflagcolor : 'red', height: '18px' }">
                  <span v-if="row.alertrelease && row.alertrelease == '1'">发</span>
                </div>
                <div v-else-if="items.field == 'modify_flag' && row.modify_flag > 0"
                  v-bind:style="{ background: Options.modifyflagcolor ? Options.modifyflagcolor : '#FFFFFF', height: '18px' }">
                </div>
                <div v-else-if="items.field == 'redo_flag' && row.redo_flag == '2'"
                  v-bind:style="{ background: 'rgb(00, 255, 00)', height: '18px' }"></div>
                <div v-else-if="items.field == 'redo_flag' && (row.redo_flag == '1' || row.redo_flag == 'M')"
                  v-bind:style="{ background: 'yellow', height: '18px' }"></div>
                <div v-else></div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field == 'rpt_itemname'">
                <div :style="ResultClassName(row)">
                  <span>{{row.rpt_itemname}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field=='result_str'">
                <div :style="ResultClass(row)">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                  <span v-else>{{row.result_str}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field=='result_diff' || items.field=='result_diffpercent'">
                <div :style="ResultClass(row,'result_diff')">
                  <span>{{row[items.field]}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field=='result_str1'">
                <div :style="ResultClass(row,'comp')">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str1}}</span>
                  <span v-else>{{row.result_str1}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field == 'cp_lastresult'">
                <div :style="ResultClass(row, 'last')">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.cp_lastresult}}</span>
                  <span v-else>{{row.cp_lastresult}}</span>
                </div>
              </template>
              <template v-slot="{ row }"
                v-else-if="items.field.indexOf('cp_lastresult') > -1 &&  items.field.length == 14">
                <div :style="ResultClass(row, items.field)">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row[items.field]}}</span>
                  <span v-else>{{row[items.field]}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field=='result6'">
                <div v-bind:style="{ backgroundColor: row.result6color }">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row[items.field]}}</span>
                  <span v-else>{{row[items.field]}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field=='result_txt'">
                <pre style="padding: 1px;white-space: pre-wrap;">{{ row.result_txt }}</pre>
                <!-- <el-input v-if="editflag" v-model="row.result_txt" type="textarea" autosize class="txtClass" @dblclick.native="tempRptItem=row,dialogResultTxtVisible = true,ResultTxt = row.result_txt"></el-input> -->
              </template>
              <template v-slot:edit="{ row, rowIndex }" v-if="items.field == 'rpt_itemname'">
                <el-input v-if="editflag && row.alertrelease != '1'"
                  @keyup.space.native="dialogRptVisible = true, tempRptItem = row, $nextTick(() => { $refs.rptdialog.$refs.qcodeinput.focus(); });"
                  @keyup.enter.native="$refs.xTableResult.setActiveCell(row, 'result_str')"
                  @keyup.down.native="ResultMove(row, 1, rowIndex, 'rpt_itemname')"
                  @keyup.up.native="ResultMove(row, 0, rowIndex, 'rpt_itemname')" @change="rptitemInput(row)"
                  v-model="row.rpt_itemname" style="width:100%;height:18px" :autofocus="true"
                  ref="rptitemname"></el-input>
                <div style="height:18px" :style="ResultClassName(row)" v-else>
                  <span>{{ row.rpt_itemname }}</span>
                </div>
              </template>
              <template v-slot:edit="{ row, rowIndex }" v-else-if="items.field=='result_str'">
                <!-- <el-input v-if="editflag" v-model="row.result_str" @keyup.enter.native="AddRow(row,rowIndex,'result_str','result1')" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" style="width:100%;height:18px"></el-input> -->
                <el-input v-model="row.result_str" style="width: 100%;18px" ref="rinput"
                  @keyup.enter.native="AddRow(row,rowIndex,'result_str','result1')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" @dblclick.native="ResultDblClick"
                  v-if="editflag && row.alertrelease != '1'">
                  <i :class="iconclass" slot="suffix" @click="handleIconClick"
                    v-show="tableDataResultAll.length > 0 && Options.showrptitemvalbyfocus > 0"></i>
                </el-input>
                <div ref="selectDialog" v-if="editflag && row.alertrelease != '1'" class="reqitem-dialog"
                  v-show="textvalueshow" style="width:100%;min-width: 240px">
                  <div class="reqitem-select">
                    <vxe-table :data.sync="tableDataResultAll" max-height="250px" stripe resizable header-align="center"
                      show-header-overflow highlight-hover-row :keyboard-config="keyConfig" show-overflow="ellipsis"
                      size="mini" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}"
                      @cell-click="ResultTextClick($event, row)" status-msg-group="none" class="ResultTxtTable">
                      <!-- <vxe-table-column v-for="item in allReqsheetTable" :key="item.id" :field="item.data" :title="item.label" :width="item.width" :align="item.align" show-overflow-tooltip></vxe-table-column> -->
                      <vxe-table-column field="textvalue" title="文字结果" width="160px" align="left" header-align="center"
                        show-overflow-tooltip>
                        <template v-slot="{ row }">
                          <div :style="ResultClass(row)">
                            <span>{{row.textvalue}}</span>
                          </div>
                        </template>
                      </vxe-table-column>
                      <vxe-table-column field="result_flag" title="结果标志" width="80px" align="center"
                        show-overflow-tooltip>
                        <template v-slot="{ row }">
                          <span>{{ ReusltflagName(row.result_flag) }}</span>
                        </template>
                      </vxe-table-column>
                      <vxe-table-column field="redoflag" title="复查标志" width="60px" align="center"
                        show-overflow-tooltip></vxe-table-column>
                      <vxe-table-column field="inputcode" title="输入码" width="80px" align="center"
                        show-overflow-tooltip></vxe-table-column>
                      <vxe-table-column field="seq" title="序号" width="40px" align="center"
                        show-overflow-tooltip></vxe-table-column>
                      <vxe-table-column field="containtext" title="录入码" width="100px" align="center"
                        show-overflow-tooltip></vxe-table-column>
                      <!-- <vxe-table-column field="col_name" title="字段名称" width="80"></vxe-table-column> -->
                    </vxe-table>
                  </div>
                </div>
                <!-- <el-autocomplete v-if="editflag" :popper-append-to-body="false" v-model="row.result_str" :fetch-suggestions="querySearch" placeholder="" @select="selectchange($event,row)" @keyup.enter.native="AddRow(row,rowIndex,'result_str','result1')" popper-class="mini-select rselect" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')">-->
                <!-- <i class="el-icon-caret-bottom el-input__icon" slot="suffix" @click="handleIconClick"></i> -->
                <!--<template slot-scope="{ item }">
                              <div class="name">{{ item.textvalue }}</div>
                          </template>
                      </el-autocomplete> -->
                <!-- <el-select v-if="editflag" v-model="row.result_str" @keyup.enter.native="AddRow(row,rowIndex,'result_str','result1')" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" style="width:100%;height:18px" allow-create filterable @blur="selectBlur($event, row)" @change="selectchange($event,row)">
                          <el-option v-for="item in tableDataResultAll" :key="item.seq" :value="item.textvalue" :label="item.textvalue"></el-option>
                      </el-select> -->
                <div style="height:18px" :style="ResultClass(row)" v-else>
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                  <span v-else>{{row.result_str}}</span>
                </div>
              </template>
              <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result1'">
                <el-input v-if="editflag" v-model="row.result1"
                  @keyup.enter.native="AddRow(row,rowIndex,'result1','result2')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result1')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result1')" style="width:100%;height:18px"></el-input>
                <span v-else style="height:18px">{{row.result1}}</span>
              </template>
              <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result2'">
                <el-input v-if="editflag" v-model="row.result2"
                  @keyup.enter.native="AddRow(row,rowIndex,'result2','result3')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result2')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result2')" style="width:100%;height:18px"></el-input>
                <span v-else style="height:18px">{{row.result2}}</span>
              </template>
              <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result3'">
                <el-input v-if="editflag" v-model="row.result3"
                  @keyup.enter.native="AddRow(row,rowIndex,'result3','result4')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result3')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result3')" style="width:100%;height:18px"></el-input>
                <span v-else style="height:18px">{{row.result3}}</span>
              </template>
              <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result4'">
                <el-input v-if="editflag" v-model="row.result4"
                  @keyup.enter.native="AddRow(row,rowIndex,'result4','result_txt')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result4')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result4')" style="width:100%;height:18px"></el-input>
                <span v-else style="height:18px">{{row.result4}}</span>
              </template>
              <template v-slot:edit="{ row }" v-else-if="items.field=='result_txt'">
                <el-input v-if="editflag" v-model="row.result_txt" type="textarea" autosize class="txtClass"
                  @dblclick.native="tempRptItem=row,dialogResultTxtVisible = true,ResultTxt = row.result_txt"></el-input>
                <pre v-else style="height:18px">{{row.result_txt}}</pre>
              </template>
              <template v-slot:edit="{ row }" v-else-if="items.field=='redo_flag'">
                <span style="height:18px">{{ row.redo_flag == '0'?'无':row.redo_flag == '1'?'需':row.redo_flag ==
                  'M'?'需':row.redo_flag == '2'?'已':row.redo_flag == 'N'?'无':''}}</span>
              </template>
              <template v-slot:edit="{ row }" v-else>
                <span style="height:18px">{{row[items.field]}}</span>
              </template>
            </vxe-table-column>
          </vxe-table>
          <div v-if="Options.showoptionalrptitemgroup == '1'"
            style="overflow: hidden;position: absolute;right:0px;bottom: 20px;z-index: 1;width: 280px;">
            <div style="overflow: auto; text-align: right">
              <table style="width:100%;border:1px solid #cccccc;" border="0">
                <tr>
                  <td style="width:100px;"><span style="color:blue;">项目过滤组选择：</span></td>
                  <td style="width:180px;">
                    <el-select v-model="itemcombid" placeholder="请选择" style="width:100%" clearable @change="CombChange">
                      <el-option v-for="(item, index) in Options.rptitemCombKindOptions" :key="index" :label="item.label"
                        :value="item.value"></el-option>
                    </el-select>
                  </td>
                </tr>
              </table>
            </div>
          </div>
        </div>
        <div v-if="Options.doubleresultcol > 0" :style="'width:49%;float:left;' + 'height:' + SetResultHeight()">
          <vxe-table :data.sync="resultlist1" @current-change="currentResultChangeEvent1" :sort-config="{ trigger: 'cell' }"
            :edit-config="{ trigger: 'click', mode: 'cell', showStatus: true, showIcon: false, activeMethod: activeMethod }"
            :mouse-config="{ selected: true }" :select-config="selectConfig" config-record-key="ResultTable1"
            :tableid="tableid1" @cell-dblclick="DblEvent" @cell-click="ResultCellClick1" @edit-actived="ResultActive"
            @edit-closed="ResultClose" :cell-class-name="ColumnClassName" :height="h" highlight-current-row
            ref="xTableResult1" resizable highlight-hover-column border show-header-overflow="tooltip"
            show-overflow="tooltip" header-align="center" :loading="loadingResult" status-msg-group="none" size="mini"
            :stripe="false" :width="w" :start-index="this.Options.doubleresultrows - 0" class="ResultTable">
            <vxe-table-column type="index" width="30px" v-if="Options['input_hideresultno'] == '0'"></vxe-table-column>

            <!-- <vxe-table-column field="rpt_itemname"  title="检验项目" key="rpt_itemname" width="200px">
                          <template v-slot:edit="{ row,rowIndex }">
                              <el-input v-if="editflag" @keyup.space.native="dialogRptVisible=true,tempRptItem=row,$nextTick(() => {$refs.rptdialog.$refs.qcodeinput.focus();});" @keyup.enter.native="$refs.xTableResult.setActiveCell(row,'result_str')" @keyup.down.native="ResultMove(row,1,rowIndex,'rpt_itemname')" @keyup.up.native="ResultMove(row,0,rowIndex,'rpt_itemname')" @change="rptitemInput(row)" v-model="row.rpt_itemname" style="width:100%;height:18px" :autofocus="true" ref="rptitemname"></el-input>
                              <span v-else style="height:18px">{{row.rpt_itemname}}</span>
                          </template>

                          </vxe-table-column> -->
            <!-- <vxe-table-column v-else field="rpt_itemname" title="检验项目" key="rpt_itemname" width="200px" :edit-render="{name: 'input', autoselect: true}">
                          <template v-slot:edit="{ row,rowIndex }">
                              <el-input @keyup.space.native="dialogRptVisible=true,tempRptItem=row,$nextTick(() => {$refs.rptdialog.$refs.qcodeinput.focus();});" @keyup.enter.native="$refs.xTableResult.setActiveCell(row,'result_str')" @keyup.down.native="ResultMove(row,1,rowIndex,'rpt_itemname')" @keyup.up.native="ResultMove(row,0,rowIndex,'rpt_itemname')" @change="rptitemInput(row)" v-model="row.rpt_itemname" style="width:100%;height:18px" :autofocus="true" ref="rptitemname"></el-input>
                          </template>
                      </vxe-table-column> -->
            <!-- <vxe-table-column field="result_str" v-if="!editflag" title="检验结果" key="result_str" width="100px"> </vxe-table-column> -->
            <!-- <vxe-table-column field="result_str"  title="检验结果" key="result_str" width="100px" :edit-render="{name: 'input', autoselect: true}" :align="Options.resultstralignmentright>0?'right':'left'">
                          <template v-if="editflag" v-slot:edit="{ row,rowIndex }">
                              <el-input v-model="row.result_str" @keyup.enter.native="AddRow(row,rowIndex)" @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')" @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" style="width:100%;height:18px"></el-input>
                          </template>
                          <template v-else v-slot="{ row,rowIndex }">
                              <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                              <span v-else>{{row.result_str}}</span>
                          </template>
                      </vxe-table-column> -->
            <vxe-table-column :field="items.field" :title="items.title" :width="items.width"
              v-for="(items) in tableResultColumn" v-bind:key="items.field"
              :edit-render="{ name: 'input', autoselect: true }" header-align="center">
              <template v-slot="{ row }"
                v-if="items.field == 'alertflag' || items.field == 'redo_flag' || items.field == 'modify_flag'">
                <div v-if="items.field == 'alertflag' && row.alertflag > 0"
                  v-bind:style="{ background: Options.alertflagcolor ? Options.alertflagcolor : 'red', height: '18px' }"></div>
                <div v-else-if="items.field == 'modify_flag' && row.modify_flag > 0"
                  v-bind:style="{ background: Options.modifyflagcolor ? Options.modifyflagcolor : '#FFFFFF', height: '18px' }">
                </div>
                <div v-else-if="items.field == 'redo_flag' && row.redo_flag == '2'"
                  v-bind:style="{ background: 'rgb(00, 255, 00)', height: '18px' }"></div>
                <div v-else-if="items.field == 'redo_flag' && (row.redo_flag == '1' || row.redo_flag == 'M')"
                  v-bind:style="{ background: 'yellow', height: '18px' }"></div>
                <div v-else></div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field == 'rpt_itemname'">
                <div :style="ResultClassName(row)">
                  <span>{{row.rpt_itemname}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field=='result_str'">
                <div :style="ResultClass(row)">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                  <span v-else>{{row.result_str}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field=='result_str1'">
                <div :style="ResultClass(row,'comp')">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str1}}</span>
                  <span v-else>{{row.result_str1}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field == 'cp_lastresult'">
                <div :style="ResultClass(row, 'last')">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.cp_lastresult}}</span>
                  <span v-else>{{row.cp_lastresult}}</span>
                </div>
              </template>
              <template v-slot="{ row }"
                v-else-if="items.field.indexOf('cp_lastresult') > -1 &&  items.field.length == 14">
                <div :style="ResultClass(row, items.field)">
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row[items.field]}}</span>
                  <span v-else>{{row[items.field]}}</span>
                </div>
              </template>
              <template v-slot="{ row }" v-else-if="items.field=='result_txt'">
                <pre style="padding: 1px;white-space: pre-wrap;">{{ row.result_txt }}</pre>
              </template>
              <template v-slot:edit="{ row, rowIndex }" v-if="items.field == 'rpt_itemname'">
                <el-input v-if="editflag && row.alertrelease != '1'"
                  @keyup.space.native="dialogRptVisible = true, tempRptItem = row, $nextTick(() => { $refs.rptdialog.$refs.qcodeinput.focus(); });"
                  @keyup.enter.native="$refs.xTableResult1.setActiveCell(row, 'result_str')"
                  @keyup.down.native="ResultMove(row, 1, rowIndex, 'rpt_itemname')"
                  @keyup.up.native="ResultMove(row, 0, rowIndex, 'rpt_itemname')" @change="rptitemInput(row)"
                  v-model="row.rpt_itemname" style="width:100%;height:18px" :autofocus="true"
                  ref="rptitemname"></el-input>
                <div style="height:18px" :style="ResultClassName(row)" v-else>
                  <span>{{ row.rpt_itemname }}</span>
                </div>
              </template>
              <template v-slot:edit="{ row, rowIndex }" v-else-if="items.field=='result_str'">
                <el-input v-model="row.result_str" style="width: 100%;18px" ref="rinput"
                  @keyup.enter.native="AddRow1(row,rowIndex,'result_str','result1')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result_str')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result_str')" @dblclick.native="ResultDblClick"
                  v-if="editflag && row.alertrelease != '1'">
                  <i :class="iconclass" slot="suffix" @click="handleIconClick"
                    v-show="tableDataResultAll.length > 0 && Options.showrptitemvalbyfocus > 0"></i>
                </el-input>
                <div ref="selectDialog" v-if="editflag && row.alertrelease != '1'" class="reqitem-dialog"
                  v-show="textvalueshow" style="width:100%;min-width: 240px">
                  <div class="reqitem-select">
                    <vxe-table :data.sync="tableDataResultAll" max-height="250px" stripe resizable header-align="center"
                      show-header-overflow highlight-hover-row :keyboard-config="keyConfig" show-overflow="ellipsis"
                      size="mini" :select-config="{reserve: true}" :sort-config="{trigger: 'cell'}"
                      @cell-click="ResultTextClick($event, row)" status-msg-group="none" class="ResultTxtTable">
                      <vxe-table-column field="textvalue" title="文字结果" width="160px" align="left" header-align="center"
                        show-overflow-tooltip>
                        <template v-slot="{ row }">
                          <div :style="ResultClass(row)">
                            <span>{{row.textvalue}}</span>
                          </div>
                        </template>
                      </vxe-table-column>
                      <vxe-table-column field="result_flag" title="结果标志" width="80px" align="center"
                        show-overflow-tooltip>
                        <template v-slot="{ row }">
                          <span>{{ ReusltflagName(row.result_flag) }}</span>
                        </template>
                      </vxe-table-column>
                      <vxe-table-column field="redoflag" title="复查标志" width="60px" align="center"
                        show-overflow-tooltip></vxe-table-column>
                      <vxe-table-column field="inputcode" title="输入码" width="80px" align="center"
                        show-overflow-tooltip></vxe-table-column>
                      <vxe-table-column field="seq" title="序号" width="40px" align="center"
                        show-overflow-tooltip></vxe-table-column>
                      <vxe-table-column field="containtext" title="录入码" width="100px" align="center"
                        show-overflow-tooltip></vxe-table-column>
                    </vxe-table>
                  </div>
                </div>
                <div style="height:18px" :style="ResultClass(row)" v-else>
                  <span v-if="Options.resultstrbold=='1'" style="font-weight:bold">{{row.result_str}}</span>
                  <span v-else>{{row.result_str}}</span>
                </div>
              </template>
              <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result1'">
                <el-input v-if="editflag" v-model="row.result1"
                  @keyup.enter.native="AddRow1(row,rowIndex,'result1','result2')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result1')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result1')" style="width:100%;height:18px"></el-input>
                <span v-else style="height:18px">{{row.result1}}</span>
              </template>
              <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result2'">
                <el-input v-if="editflag" v-model="row.result2"
                  @keyup.enter.native="AddRow1(row,rowIndex,'result2','result3')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result2')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result2')" style="width:100%;height:18px"></el-input>
                <span v-else style="height:18px">{{row.result2}}</span>
              </template>
              <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result3'">
                <el-input v-if="editflag" v-model="row.result3"
                  @keyup.enter.native="AddRow1(row,rowIndex,'result3','result4')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result3')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result3')" style="width:100%;height:18px"></el-input>
                <span v-else style="height:18px">{{row.result3}}</span>
              </template>
              <template v-slot:edit="{ row,rowIndex }" v-else-if="items.field=='result4'">
                <el-input v-if="editflag" v-model="row.result4"
                  @keyup.enter.native="AddRow1(row,rowIndex,'result4','result_txt')"
                  @keyup.down.native="ResultMove(row,1,rowIndex,'result4')"
                  @keyup.up.native="ResultMove(row,0,rowIndex,'result4')" style="width:100%;height:18px"></el-input>
                <span v-else style="height:18px">{{row.result4}}</span>
              </template>
              <template v-slot:edit="{ row }" v-else-if="items.field=='result_txt'">
                <el-input v-if="editflag" v-model="row.result_txt" type="textarea" autosize class="txtClass"
                  @dblclick.native="tempRptItem=row,dialogResultTxtVisible = true,ResultTxt = row.result_txt"></el-input>
                <pre v-else style="height:18px">{{row.result_txt}}</pre>
              </template>
              <template v-slot:edit="{ row }" v-else-if="items.field=='redo_flag'">
                <span style="height:18px">{{ row.redo_flag == '0'?'无':row.redo_flag == '1'?'需':row.redo_flag ==
                  'M'?'需':row.redo_flag == '2'?'已':row.redo_flag == 'N'?'无':''}}</span>
              </template>
              <template v-slot:edit="{ row }" v-else>
                <span style="height:18px">{{row[items.field]}}</span>
              </template>
            </vxe-table-column>
          </vxe-table>
          <div v-if="Options.showoptionalrptitemgroup == '1'"
            style="overflow: hidden;position: absolute;right:0px;bottom: 20px;z-index: 1;width: 280px;">
            <div style="overflow: auto; text-align: right">
              <table style="width:100%;border:1px solid #cccccc;" border="0">
                <tr>
                  <td style="width:100px;"><span style="color:blue;">项目过滤组选择：</span></td>
                  <td style="width:180px;">
                    <el-select v-model="itemcombid" placeholder="请选择" style="width:100%" clearable @change="CombChange">
                      <el-option v-for="(item, index) in Options.rptitemCombKindOptions" :key="index" :label="item.label"
                        :value="item.value"></el-option>
                    </el-select>
                  </td>
                </tr>
              </table>
            </div>
          </div>
        </div>
        <div v-if="Options.resultdisplayinfos" style="width:100%;height:95px;">
          <table style="width:100%;border:1px solid #cccccc;" border="0">
            <tr>
              <td style="width:90px;"><span style="color:blue;">附加信息显示：</span></td>
              <td colspan="3">
                <el-checkbox v-if="Options.resultdisplayinfos.indexOf('1') > -1" v-model="instradvieshow"
                  style="margin-left:10px;">仪器诊断</el-checkbox>
                <el-checkbox v-if="Options.resultdisplayinfos.indexOf('2') > -1" v-model="labadvieshow"
                  style="margin-left:10px;">实验室意见</el-checkbox>
              </td>
            </tr>
            <tr>
              <td v-if="Options.resultdisplayinfos.indexOf('1') > -1 && instradvieshow" style="width:90px;">仪器诊断：</td>
              <td v-if="Options.resultdisplayinfos.indexOf('1') > -1 && instradvieshow">
                <el-input type="textarea" :rows="3" v-model="PatientInfo.instr_advice" readonly></el-input>
              </td>
              <td v-if="Options.resultdisplayinfos.indexOf('2') > -1 && labadvieshow" style="width:90px;">实验室意见：</td>
              <td v-if="Options.resultdisplayinfos.indexOf('2') > -1 && labadvieshow">
                <el-input type="textarea" :rows="3" v-model="PatientInfo.lab_advice" readonly></el-input>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div v-show="Options.showreportview == '1' && showtabid == 2" id="reportviewid" style="height: 100%;">
        <div v-html="reportviewstr"></div>
      </div>
    </div>
    <!-- <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告项目" :visible.sync="dialogRptVisible" @close="$refs.xTableResult.setActiveCell($refs.xTableResult.getCurrentRow(), 'rpt_itemname')">
          <rm-pop-rptitem prgno="LIS310" @cancel="dialogRptVisible=false,$refs.xTableResult.setActiveCell($refs.xTableResult.getCurrentRow(), 'rpt_itemname')" :isAllRpt="1" :rptunitid="rptunitid" :rptunitdisabled="true" @selitem="addrptitem" ref="rptdialog"></rm-pop-rptitem>
      </el-dialog> -->

    <!--多选弹窗--->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" :visible.sync="dialogRptVisible"
      :destroy-on-close="true" title="报告项目" v-if="dialogRptVisible"
      @close="linkshow = true, Options.doubleresultcol == 1 ? $refs.xTableResult1.setActiveCell($refs.xTableResult1.getCurrentRow(), 'rpt_itemname') : $refs.xTableResult.setActiveCell($refs.xTableResult.getCurrentRow(), 'rpt_itemname')">
      <rm-chkboxSelect2 prgno="LIS310"
        @cancel="dialogRptVisible = false, linkshow = true, Options.doubleresultcol == 1 ? $refs.xTableResult1.setActiveCell($refs.xTableResult1.getCurrentRow(), 'rpt_itemname') : $refs.xTableResult.setActiveCell($refs.xTableResult.getCurrentRow(), 'rpt_itemname')"
        :isAllRpt="1" :rptunitid="rptunitid" :rptunitdisabled="true" @selitem="addrptitem" @selitems="SelectRptItems"
        ref="rptdialog"></rm-chkboxSelect2>
    </el-dialog>

    <!--报告项目结果选择开窗-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告项目常见结果选择"
      :visible.sync="dialogResultVisible" v-if="dialogResultVisible">
      <el-container style="border: 1px solid #eee;height:600px">
        <el-main style="overflow: hidden;padding:0 0">
          <el-input @keyup.enter.native="ResultSearchkeydown" placeholder="快速检索" prefix-icon="el-icon-search"
            ref="qcodeinput" style="width:300px;" v-model="Resultqcode"></el-input>
          <el-button @click="Resultok" icon="el-icon-circle-check" style="margin-left:10px;">确定</el-button>
          <el-button @click="Resultcancel" icon="el-icon-circle-close">取消</el-button>
          <div style="height: 564px">
            <vxe-table :data="tableDataResultS" @cell-dblclick="ResultSelect" border height="564px" highlight-current-row
              highlight-hover-row resizable size="mini" status-msg-group="none" stripe style="margin-top:10px"
              ref="xTableResultAll">
              <vxe-table-column field="textvalue" title="文字结果" width="200px"></vxe-table-column>
              <vxe-table-column field="result_flag" title="结果标志" width="60px"></vxe-table-column>
              <vxe-table-column field="redoflag" title="复查标志" width="60px"></vxe-table-column>
              <vxe-table-column field="inputcode" title="快速输入码" width="80px"></vxe-table-column>
              <vxe-table-column field="seq" title="序号" width="40px"></vxe-table-column>
              <vxe-table-column field="containtext" title="录入码" width="80px"></vxe-table-column>
              <!-- <vxe-table-column :field="item.field" :key="item.field" :title="item.title" width="100px" v-for="item in tableColumnResultAll"></vxe-table-column> -->
            </vxe-table>
          </div>
        </el-main>
      </el-container>
    </el-dialog>

    <!--报告项目文字结果选择开窗-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="报告项目常见结果选择"
      :visible.sync="dialogResultTxtVisible" v-if="dialogResultTxtVisible">
      <div>
        <el-input type="textarea" :rows="6" v-model="ResultTxt"></el-input>
      </div>
      <div>
        <table style="width:100%;border-spacing:0px;margin-top:5px">
          <tr>
            <td>
              快速查找
              <el-input v-model="Resultqcode" @keyup.enter.native="ResultSearchkeydown" placeholder="请输入要查找的信息"
                style="width:calc(100% - 60px)"></el-input>
            </td>
          </tr>
          <tr>
            <td style="width:450px">
              <vxe-table :data="tableDataResultS" :select-config="selectConfig" :keyboard-config="keyConfig"
                @cell-click="AdviceClick" @cell-dblclick="AdvicedblClick" height="300px" highlight-current-row
                highlight-hover-row resizable highlight-hover-column border show-header-overflow="tooltip"
                show-overflow="tooltip" header-align="center" size="mini" status-msg-group="none" stripe width="400px">
                <vxe-table-column field="textvalue" title="文字结果" width="200px"></vxe-table-column>
                <vxe-table-column field="result_flag" title="结果标志" width="60px"></vxe-table-column>
                <vxe-table-column field="redoflag" title="复查标志" width="60px"></vxe-table-column>
                <vxe-table-column field="inputcode" title="快速输入码" width="80px"></vxe-table-column>
                <vxe-table-column field="seq" title="序号" width="40px"></vxe-table-column>
                <vxe-table-column field="containtext" title="录入码" width="80px"></vxe-table-column>
                <!-- <vxe-table-column :field="item.field" :key="item.field" :title="item.title" width="100px" v-for="item in tableColumnResultAll"></vxe-table-column> -->
              </vxe-table>
            </td>
            <td>
              <div style="margin-left:15px">
                <el-button style="display:block" @click="AdviceSubmit()">确 定</el-button>
                <el-button style="display:block;margin-left:0px;margin-top:5px" @click="dialogResultTxtVisible = false">取
                  消</el-button>
                <el-checkbox v-model="appendChangeRow" style="margin-top:20px;display:block">追加时自动换行</el-checkbox>
                <div style="margin-top:20px">
                  <span style="color:blue;">说明:<br>单击为追加<br>双击为替换</span>
                </div>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </el-dialog>

    <!--删除撤销弹窗-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="撤销删除"
      :visible.sync="dialogDelVisible" v-if="dialogDelVisible" width="600px">
      <div>
        <vxe-table :data.sync="tableDelData" border fit height="400px" header-align="center" highlight-current-row
          highlight-hover-row ref="xTableDel" resizable show-header-overflow="tooltip" show-overflow="tooltip" size="mini"
          status-msg-group="none" stripe>
          <vxe-table-column type="selection" align="center" width="40px"></vxe-table-column>
          <vxe-table-column field="rpt_itemname" title="检验项目" width="200px"></vxe-table-column>
          <vxe-table-column field="result_str" title="修改前取值" width="100px"></vxe-table-column>
          <vxe-table-column field="opratedt" title="操作时间" width="120px"></vxe-table-column>
        </vxe-table>
      </div>
      <div style="text-align: right">
        <el-button @click="SubmitCancelDel()">确 定</el-button>
        <el-button @click="dialogDelVisible = false">取 消</el-button>
      </div>
    </el-dialog>

    <!--查看项目历史结果弹窗-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="检验项目历史结果"
      :visible.sync="dialogItemhistoryVisible" v-if="dialogItemhistoryVisible" width="820px">
      <div>
        <vxe-table :data.sync="tableItemHData" border fit height="400px" header-align="center" highlight-current-row
          highlight-hover-row ref="xTableItemH" resizable show-header-overflow="tooltip" show-overflow="tooltip"
          size="mini" status-msg-group="none" stripe>
          <vxe-table-column field="sampledate" title="样本日期" width="100px" align="center"></vxe-table-column>
          <vxe-table-column field="sampleno" title="样本号" width="60px" align="center"></vxe-table-column>
          <vxe-table-column field="rpt_itemname" title="检验项目" width="120px" align="center"></vxe-table-column>
          <vxe-table-column field="result_str" title="检验结果" width="60px" align="right" header-align="center">
            <template v-slot="{ row }">
              <div :style="ResultClass(row)">
                <span v-if="Options.resultstrbold == '1'" style="font-weight:bold">{{ row.result_str }}</span>
                <span v-else>{{ row.result_str }}</span>
              </div>
            </template>
          </vxe-table-column>
          <vxe-table-column field="specimen_name" title="标本类型" width="60px" align="center"></vxe-table-column>
          <vxe-table-column field="rechk_user" title="审核者" width="60px" align="center"></vxe-table-column>
          <vxe-table-column field="rechk_dt" title="审核时间" width="120px" align="center"></vxe-table-column>
          <vxe-table-column field="report_user" title="检验者" width="60px" align="center"></vxe-table-column>
          <vxe-table-column field="pat_no" title="病人号" width="100px"></vxe-table-column>
          <vxe-table-column field="pat_typename" title="病人类型" width="60px" align="center"></vxe-table-column>
          <!-- <vxe-table-column field="result_flag" title="标志" width="40px" align="center"></vxe-table-column> -->
        </vxe-table>
      </div>
      <div style="text-align: right;padding-top: 5px">
        <el-button @click="dialogItemhistoryVisible = false">确 定</el-button>
        <!-- <el-button @click="dialogItemhistoryVisible = false">取 消</el-button> -->
      </div>
    </el-dialog>

    <!--关联报告项目开窗-->
    <el-dialog v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="关联报告项目查看"
      :visible.sync="dialogLinkRptVisible" v-if="dialogLinkRptVisible" width="50%">
      <rm-pop-linkitem :linkitemcode="linkitemcode" :reportid="PatientInfo.reportid" :rptunitid="myrptunitid"
        :pOptions="Options" @cancel="LinkItemCancel"></rm-pop-linkitem>
    </el-dialog>
  </div>
</template>
<script>
import { Promise } from "q";
import XE from "xe-utils";
import echarts from "echarts";
export default {
  props: ["PatientInfo", "rptunitid", "pOptions", "h", "w", "checkmode"],
  name: "LIS310",
  data() {
    return {
      showtabid: 1,
      reportviewstr: "",
      DelIndex: -1,

      myrptunitid: this.rptunitid,
      tableDataResult: [],
      tableDataResult1: [],
      noupdateflag: true,
      tableDataResultOld: [],
      tableResultColumn: [],
      loadingResult: false,
      InputMsg: [],

      dialogRptVisible: false,

      selectConfig: { tigger: "row" },
      keyConfig: {
        isDel: true,
        isTab: true,
        isEdit: true
      },
      tempRptItem: {},
      xscrollflag: true,
      oldval: "", //激活时的旧result值
      //报告结果选择开窗
      dialogResultVisible: false,
      dialogResultItem: "", //报告结果项目
      Resultqcode: "",
      tableDataResultAll: [],
      tableDataResultS: [],
      tableColumnResultAll: [],
      editflag: true,
      Options: this.pOptions,
      Checkmode: this.checkmode,
      Refreshflag: false,
      ddlData: [],
      //撤销删除弹窗
      dialogDelVisible: false,
      tableDelData: [],
      //报告项目文本结果选择
      dialogResultTxtVisible: false,
      ResultTxt: "",
      appendChangeRow: false,
      //下拉框展示
      textvalueshow: false,
      iconclass: "el-icon-arrow-down",
      tableid: "",
      tableid1: "",
      //查看项目历史结果弹窗
      dialogItemhistoryVisible: false,
      tableItemHData: [],
      selresultrow: "",// 选中得行
      befromtable: "",// 选中行是哪个表
      instradvieshow: true,//显示仪器诊断
      labadvieshow: true,//显示检验意见
      itemcombid: "",
      itemcombdetail: [],
      linkitemcode: "",//关联项目代码
      dialogLinkRptVisible: false,
      rptnaIsNotDouble: false,
      celldblclickflag: false,
    };
  },
  components: {},
  created() {
    this.InitPageData();
  },
  mounted() {
    // 监听body上的点击
    document.querySelector("body").addEventListener("click", this.closeMenu);
  },
  beforeDestroy() {
    // 移除监听
    document.querySelector("body").removeEventListener("click", this.closeMenu);
  },
  updated() { },
  computed: {
    resultlist() {
      if (this.Options.showoptionalrptitemgroup == "1" && this.itemcombdetail.length > 0) {
        return this.tableDataResult.filter((item) => {
          return this.itemcombdetail.indexOf(item.rpt_itemcode) > -1;
        })
      } else {
        return this.tableDataResult;
      }
    },
    resultlist1() {
      if (this.Options.showoptionalrptitemgroup == "1" && this.itemcombdetail.length > 0) {
        return this.tableDataResult1.filter((item) => {
          return this.itemcombdetail.indexOf(item.rpt_itemcode) > -1;
        })
      } else {
        return this.tableDataResult1;
      }
    }
  },
  methods: {
    rTabclick(tab) {
      this.showtabid = tab;
      if (tab == 2) {
        this.queryreportview();
      }
    },
    queryreportview(reportid) {
      this.reportviewstr = "";
      if (!reportid) {
        reportid = this.PatientInfo.reportid;
      }
      if (reportid && reportid != "no") {
        this.$tool
          .request({
            url: "ucent/print",
            method: "post",
            data: {
              action: "reportprintview",
              reportid: reportid,
              env: "1"
            }
          })
          .then(res => {
            if (res.flag == "0") {
              this.reportviewstr = res.msg;
            } else {
              this.reportviewstr = '<embed id="embed-report" width="100%" height="' + (document.getElementById("reportviewid").clientHeight - 32) + 'px"  name="plugin" src="' + res.pdfurl + '#toolbar=0" type="application/pdf" >';
            }
          })
          .catch(e => {
            this.$alert("预览报告出错！", "错误", {
              confirmButtonText: "确定"
            });
          });
      }
    },
    queryreportpdf(reportid) {
      if (reportid != "no") {
        this.$tool
          .request({
            url: "LIS/LIS3/LIS310",
            method: "post",
            data: {
              action: "queryreportpdf",
              reportid: reportid,
            }
          })
          .then(res => {
            if (res.flag == -1) {//勾选本组报告后选择的报告不属于开启悬浮窗的报告单元
              this.$emit("ShowReportPDF", false, "", -1);
            } else {
              this.$emit("ShowReportPDF", true, res.url, res.flag);
            }
          })
          .catch(e => {
            this.$alert("报告pdf显示出错！", "错误", {
              confirmButtonText: "确定"
            });
          });
      } else {
        //无报告的情况下按当前报告单元来决定开悬浮窗还是不开
        if (this.Options.showpdfreport == "1") {
          this.$emit("ShowReportPDF", true, "", 0);
        } else {
          this.$emit("ShowReportPDF", false, "", 0);
        }
      }
    },
    InitPageData() { },
    //上方按钮功能
    //计算下结果的高度
    SetResultHeight() {
      let cutheight = 0;
      if (this.Options.showreportview == '1') {
        cutheight += 32;
      }
      if (this.Options.resultdisplayinfos) {
        cutheight += 95;
      }
      if (cutheight == 0) {
        return "100%";
      } else {
        return "calc(100% - " + cutheight + "px)";
      }
    },
    //新增
    ResultAdd() {
      return new Promise((s, f) => {
        var row = { rptunitid: this.myrptunitid, reportid: this.PatientInfo.reportid, result_str: "", rptna_edit_active: true };
        //双列模式下，统统往右侧加，不管双列每列显示行数
        if (this.Options.doubleresultcol == 1) {
          this.$refs.xTableResult1.insertAt(row, -1).then(() => {
            this.$refs.xTableResult.clearCurrentRow();
            var nowrow = this.$refs.xTableResult1.tableFullData[this.$refs.xTableResult1.tableFullData.length - 1];
            this.$refs.xTableResult1.setCurrentRow(nowrow).then(() => {
              this.$refs.xTableResult1.setActiveCell(nowrow, "rpt_itemname").then(() => {
                s();
              });
            });
          });
        } else {
          this.$refs.xTableResult.insertAt(row, -1).then(() => {
            var nowrow = this.$refs.xTableResult.tableFullData[this.$refs.xTableResult.tableFullData.length - 1];
            this.$refs.xTableResult.setCurrentRow(nowrow).then(() => {
              //this.linkshow = true;
              this.$refs.xTableResult.setActiveCell(nowrow, "rpt_itemname").then(() => {
                s();
              });
            });
          });
        }
      });

      //this.$refs.xTableResult.$refs.tableBody.$children[0].focus();
    },
    ResultAddAsync() {
      if (!this.editflag) {
        return;
      }
      this.ResultAdd().then(() => {
        this.$emit("change");
        if (this.Options.doubleresultcol == 1) {
          this.$refs.xTableResult1.$refs.tableBody.$children[0].focus();
        } else {
          this.$refs.xTableResult.$refs.tableBody.$children[0].focus();
        }
      });
    },
    //删除
    ResultDel() {
      let row = "";
      if (this.Options.doubleresultcol == "1") {
        row = this.selresultrow;
      }
      else {
        row = this.$refs.xTableResult.getCurrentRow();
      }
      if (!this.editflag) {
        return;
      }
      if (row.alertrelease == "1") {
        this.$alert("当前结果已单独上报危急值,请先召回危急值再删除", "提示");
        return;
      }
      if (this.Options.modifyresultmsg == "2") {
        if (this.noupdateflag) {
          this.$confirm("是否修改当前项目结果", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            focusCancelButton: false,
            type: "warning"
          })
            .then(() => {

              if (this.Options.doubleresultcol == "1" && this.befromtable == "1") {
                this.$table.DelRecordSelect(this.$refs.xTableResult1, this.DelIndex, this);
                var nowrow = this.$refs.xTableResult1.getCurrentRow();
                this.linkshow = true;
                this.$refs.xTableResult1.setActiveCell(nowrow, "rpt_itemname");
                this.noupdateflag = false;
              }
              else {
                this.$table.DelRecordSelect(this.$refs.xTableResult, this.DelIndex, this);
                var nowrow = this.$refs.xTableResult.getCurrentRow();
                this.linkshow = true;
                this.$refs.xTableResult.setActiveCell(nowrow, "rpt_itemname");
                this.noupdateflag = false;
              }
            })
            .catch(() => {
              this.noupdateflag = false;
            });
        }
      } else if (this.Options.modifyresultmsg == "3") {
        this.$confirm("是否修改当前项目结果", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          focusCancelButton: false,
          type: "warning"
        }).then(() => {

          if (this.Options.doubleresultcol == "1" && this.befromtable == "1") {
            this.$table.DelRecordSelect(this.$refs.xTableResult1, this.DelIndex, this);
            var nowrow = this.$refs.xTableResult1.getCurrentRow();
            this.linkshow = true;
            this.$refs.xTableResult1.setActiveCell(nowrow, "rpt_itemname");
          }
          else {
            this.$table.DelRecordSelect(this.$refs.xTableResult, this.DelIndex, this);
            var nowrow = this.$refs.xTableResult.getCurrentRow();
            this.linkshow = true;
            this.$refs.xTableResult.setActiveCell(nowrow, "rpt_itemname");
          }
        });
      } else {
        if (this.Options.doubleresultcol == "1" && this.befromtable == "1") {
          this.$table.DelRecordSelect(this.$refs.xTableResult1, this.DelIndex, this);
          var nowrow = this.$refs.xTableResult1.getCurrentRow();
          this.linkshow = true;
          this.$refs.xTableResult1.setActiveCell(nowrow, "rpt_itemname");
        }
        else {
          this.$table.DelRecordSelect(this.$refs.xTableResult, this.DelIndex, this);
          var nowrow = this.$refs.xTableResult.getCurrentRow();
          this.linkshow = true;
          this.$refs.xTableResult.setActiveCell(nowrow, "rpt_itemname");
        }
      }
    },
    ResultDelAsync() {
      new Promise(resolve => {
        this.ResultDel();
        resolve();
      }).then(() => {
        this.$emit("change");
        if (this.Options.doubleresultcol == "1" && this.befromtable == "1") {
          this.$refs.xTableResult1.$refs.tableBody.$children[0].focus();
        }
        else {
          this.$refs.xTableResult.$refs.tableBody.$children[0].focus();
        }
      });
    },
    ClearNoDoItems() {
      return new Promise((s, f) => {
        if (this.editflag) {
          var delrow = [];
          this.$refs.xTableResult.tableFullData.forEach(t => {
            if (!t.result_str || t.result_str == "" || t.result_str == "未做") {
              delrow.push(t);
            }
          });
          delrow.forEach(element => {
            this.$refs.xTableResult.remove(element);
          });
          if (this.Options.doubleresultcol == "1" && this.$refs.xTableResult1) {
            this.$refs.xTableResult1.tableFullData.forEach(t => {
              if (!t.result_str || t.result_str == "" || t.result_str == "未做") {
                delrow.push(t);
              }
            });
            delrow.forEach(element => {
              this.$refs.xTableResult1.remove(element);
            });
          }
          // var tmplis = this.tableDataResult.filter(t => t.result_str && t.result_str != "" && t.result_str != "未做");
          // this.tableDataResult = tmplis;
          s();
        } else {
          f();
        }
      });
    },
    //表格功能
    currentResultChangeEvent({ row }) {
      this.befromtable = "0";
      this.selresultrow = row;
      if (this.$refs.xTableResult1) this.$refs.xTableResult1.clearCurrentRow();
    },
    //表格功能
    currentResultChangeEvent1({ row }) {
      this.befromtable = "1";
      this.selresultrow = row;
      if (this.$refs.xTableResult) this.$refs.xTableResult.clearCurrentRow();
    },
    ColumnClassName({ seq, row, rowIndex, $rowIndex, column }) {
      if (column.property != "rpt_itemname" && column.property != "result_str" && column.property != "alertflag" && column.property != "redo_flag" && column.property != "modify_flag" && column.property != "result1" && column.property != "result2" && column.property != "result3" && column.property != "result4" && column.property != "result_txt") {
        var style = "";
        if (row.keyitem == "1") style += "fontbold";
        style += " disabled-cell paddingcolumn";
        return style;
      }
      if (column.property == "alertflag" || column.property == "redo_flag" || column.property == "modify_flag") {
        return "disabled-cell";
      }
      if (column.property == "rpt_itemname") {
        var style = "";
        if (!row.rptna_edit_active && this.Options.allowrptnaedit != "1") style += " disabled-cell ";
        if (row.keyitem == "1") style += "fontbold";
        if (row.lab_rptunit_item_unprintflag == "1") {
          style += " unprint";
          return style;
        }
        if (row.alertflag) {
          if (row.alertflag.trim() - 0) {
            style += " danger paddingcolumn";
            return style;
          } else {
            style += " paddingcolumn";
            return style;
          }
        } else {
          style += " paddingcolumn";
          return style;
        }
      }
      if (row.keyitem == "1") {
        return "fontbold";
      }
    },
    ResultClass(row, type) {
      var stylestr = "padding:0 3px;";
      if (this.Options.resultcolor_mode == "1") stylestr += "color:";
      else stylestr += "background-color:";
      var flag = row.result_flag;
      //异常结果颜色
      if (row.exceptionflag && row.exceptionflag == "1") flag = "A";
      if (type && type == "last") flag = row.cp_lastresultflag;
      if (type && type.indexOf('cp_lastresult') > -1) flag = row[type.substring(0, 13) + 'flag' + type.substring(13)];
      if (type && type == "comp") {
        var comp_itemcode = row.comp_itemcode;
        var rpt_comp = [];
        rpt_comp = this.tableDataResult.filter(item => item.rpt_itemcode == comp_itemcode);
        if (this.Options.doubleresultcol == 1) {
          if (rpt_comp.length == 0) {
            rpt_comp = this.tableDataResult1.filter(item => item.rpt_itemcode == comp_itemcode);
          }
        }
        if (rpt_comp.length > 0) {
          flag = rpt_comp[0].result_flag;
        }
        else {
          flag = "M";
        }
      }
      if (type && type == "result_diff") {
        if (row.result_diffcolor == "1") {//高
          flag = "H";
        } else if (row.result_diffcolor == "0") {//低
          flag = "L";
        } else {//正常
          flag = "M";
        }
      }
      switch (flag) {
        case "M":
          stylestr += this.Options.resultcolor_m;
          break;
        case "H":
          stylestr += this.Options.resultcolor_h;
          break;
        case "L":
          stylestr += this.Options.resultcolor_l;
          break;
        case "P":
          stylestr += this.Options.resultcolor_p;
          break;
        case "W":
          stylestr += this.Options.resultcolor_w;
          break;
        case "E":
          stylestr += this.Options.resultcolor_e;
          break;
        case "Q":
          stylestr += this.Options.resultcolor_w;
          break;
        case "A":
          stylestr += this.Options.resultcolor_a;
          break;
        default:
          stylestr += this.Options.resultcolor_m;
          break;
      }

      if (row.result_str == "未做") {
        stylestr += ";color: #0095D9";
      }
      return stylestr;
    },
    ResultClassName(row) {
      var stylestr = "padding:0 3px;";
      if (row.alertflag > 0) stylestr += "background-color:" + (this.Options.alertflagcolor ? this.Options.alertflagcolor : "red") + ";";
      if (row.linkitemfalg == "1") stylestr += "text-decoration:underline;";
      return stylestr;
    },
    ReusltflagName(flag) {
      switch (flag) {
        case "M":
          return "正常";
        case "H":
          return "偏高";
        case "L":
          return "偏低";
        case "P":
          return "阳性";
        case "W":
          return "弱阳性";
        case "E":
          return "错误";
        case "Q":
          return "弱阳性";
        default:
          return "";
      }
    },
    ResultActive({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, cell }) {
      //每次激活都要先把值塞给oldval，不然切换报告第一个可编辑第二个不可编辑oldval还是第一次的值
      //一旦有延迟偶发性导致editflag为true(切换报告导致清空PatientInfo),ResultClose就会把当前报告的值与可编辑的报告的值进行比较，产生问题
      this.oldval = row[column.property];
      if (!this.editflag) return;
      if (column.property == "result_str") {
        this.iconclass = "el-icon-arrow-down";
        this.textvalueshow = false;
        this.QueryResultAll(row.rpt_itemcode, 0);
        //this.oldval = row.result_str;
      }
      if (column.property == "result1") {
        this.QueryResultAll(row.rpt_itemcode, 1);
        //this.oldval = row.result_str;
      }
      if (column.property == "result2") {
        this.QueryResultAll(row.rpt_itemcode, 2);
        //this.oldval = row.result_str;
      }
      if (column.property == "result3") {
        this.QueryResultAll(row.rpt_itemcode, 3);
        //this.oldval = row.result_str;
      }
      if (column.property == "result4") {
        this.QueryResultAll(row.rpt_itemcode, 4);
        //this.oldval = row.result_str;
      }
      if (column.property == "result_txt") {
        this.QueryResultAll(row.rpt_itemcode, 7);
        //this.oldval = row.result_str;
      }
      if (column.property == "rpt_itemname") {
        if (row.linkitemfalg == "1") {
          console.log("link", this.linkshow);
          if (!this.linkshow) {
            this.linkitemcode = row.rpt_itemcode;
            this.dialogLinkRptVisible = true;
          }
          this.linkshow = false;
        }
        // this.$nextTick(() => {
        //     if (this.$refs.rptitemname) {
        //         this.$refs.rptitemname.focus();
        //     }
        // });
        //this.oldval = row.rpt_itemcode;
      }
    },
    // ResultClick({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, cell }) {
    //     if (column.property == "rpt_itemname") {
    //         if (this.Options.linkdt.find(item => item.rpt_itemcode == row.rpt_itemcode)) {
    //             this.dialogLinkRptVisible = true;
    //         }
    //     }
    // },
    ResultClose({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, cell }) {
      if (!this.editflag) return;
      if (column.property == "result_str") {
        if (row.result_str) {
          var selectrow = this.tableDataResultAll.filter(item => item.inputcode == row.result_str);
          if (selectrow.length > 0) {
            row.result_str = selectrow[0].textvalue;
          }
        }
        //if (this.oldval != row.result_str) this.$emit("change");
        this.StrChange(row);
        this.textvalueshow = false;
        //this.CalcRef(row);
      }
      if (column.property == "rpt_itemname") {
        this.linkshow = false;
        //if (this.oldval != row.rpt_itemcode) this.$emit("change");
      }
      if (this.oldval != row[column.property]) this.$emit("change");
      //实时计算sco值，并且显示结果1、2、3选中。
      if (this.Options.realcalcsoc == "1" && this.Options.showresult1 == "1" && this.Options.showresult2 == "1" && this.Options.showresult3 == "1") {
        if (column.property == "result1" || column.property == "result3") {
          if (!isNaN(parseFloat(row.result1)) && !isNaN(parseFloat(row.result3)) && parseFloat(row.result3) > 0) {
            var digit = parseInt(this.Options.realcalcsocdecimal);
            var result2 = (parseFloat(row.result1) / parseFloat(row.result3)).toFixed(digit);
            row.result2 = result2;
          }
        }
      }
    },
    async rptitemInput(row) {
      this.ddlData = await this.$ddldata.getrptunititem(this.myrptunitid);
      var select = this.ddlData.filter(item => item.rpt_itemcode.toUpperCase() == row.rpt_itemname.toUpperCase() || item.itemcode_en.toUpperCase() == row.rpt_itemname.toUpperCase() || item.rpt_itemname.toUpperCase() == row.rpt_itemname.toUpperCase() || item.inputcode.toUpperCase() == row.rpt_itemname.toUpperCase());
      if (select && select.length > 0) {
        this.tempRptItem = row;
        this.addrptitem(select[0].rpt_itemcode, select[0].rpt_itemname, select[0]);
      } else {
        row.rpt_itemname = "";
      }
    },
    AddRow(row, rowIndex, coltype1, coltype2) {
      var lastrow = this.$refs.xTableResult.tableFullData[this.$refs.xTableResult.tableFullData.length - 1];
      var hascol = false;
      var selectdata = [];
      if (this.tableResultColumn) {
        selectdata = this.tableResultColumn.find(item => item.field == coltype2);
      }
      if (selectdata) {
        hascol = true;
      }
      if (lastrow._XID == row._XID && !hascol) {
        var newrow = { rptunitid: this.myrptunitid, reportid: this.PatientInfo.reportid, rptna_edit_active: true };
        this.$refs.xTableResult.insertAt(newrow, -1).then(() => {
          var nowrow = this.$refs.xTableResult.tableFullData[this.$refs.xTableResult.tableFullData.length - 1];
          this.$nextTick(() => {
            this.$refs.xTableResult.setCurrentRow(nowrow);
            this.$refs.xTableResult.clearSelected();
            this.$refs.xTableResult.clearActived();
            //this.linkshow = true;
            this.$refs.xTableResult.setActiveCell(nowrow, "rpt_itemname");
          });
        });
      } else {
        var thisrow = this.$refs.xTableResult.tableFullData[rowIndex + 1];
        if (hascol) thisrow = this.$refs.xTableResult.getCurrentRow();
        this.$nextTick(() => {
          this.$refs.xTableResult.setCurrentRow(thisrow);
          this.$refs.xTableResult.clearSelected();
          this.$refs.xTableResult.clearActived();
          this.$nextTick(() => {
            if (thisrow && hascol) {
              this.$refs.xTableResult.setActiveCell(thisrow, coltype2);
            } else {

              if (thisrow.hasOwnProperty("rpt_itemcode") && thisrow.rpt_itemcode) {
                this.$refs.xTableResult.setActiveCell(thisrow, "result_str");
              } else {
                //this.linkshow = true;
                this.$refs.xTableResult.setActiveCell(thisrow, "rpt_itemname");
              }
            }
          });
        });
      }
    },
    AddRow1(row, rowIndex, coltype1, coltype2) {
      var lastrow = this.$refs.xTableResult1.tableFullData[this.$refs.xTableResult1.tableFullData.length - 1];
      var hascol = false;
      var selectdata = [];
      if (this.tableResultColumn) {
        selectdata = this.tableResultColumn.find(item => item.field == coltype2);
      }
      if (selectdata) {
        hascol = true;
      }
      if (lastrow._XID == row._XID && !hascol) {
        var newrow = { rptunitid: this.myrptunitid, reportid: this.PatientInfo.reportid, rptna_edit_active: true };
        this.$refs.xTableResult1.insertAt(newrow, -1).then(() => {
          var nowrow = this.$refs.xTableResult1.tableFullData[this.$refs.xTableResult1.tableFullData.length - 1];
          this.$nextTick(() => {
            this.$refs.xTableResult1.setCurrentRow(nowrow);
            this.$refs.xTableResult1.clearSelected();
            this.$refs.xTableResult1.clearActived();
            //this.linkshow = true;
            this.$refs.xTableResult1.setActiveCell(nowrow, "rpt_itemname");
          });
        });
      } else {
        var thisrow = this.$refs.xTableResult1.tableFullData[rowIndex + 1];
        if (hascol) thisrow = this.$refs.xTableResult1.getCurrentRow();
        this.$nextTick(() => {
          this.$refs.xTableResult1.setCurrentRow(thisrow);
          this.$refs.xTableResult1.clearSelected();
          this.$refs.xTableResult1.clearActived();
          this.$nextTick(() => {
            if (thisrow && hascol) {
              this.$refs.xTableResult1.setActiveCell(thisrow, coltype2);
            } else {

              if (thisrow.hasOwnProperty("rpt_itemcode") && thisrow.rpt_itemcode) {
                this.$refs.xTableResult1.setActiveCell(thisrow, "result_str");
              } else {
                //this.linkshow = true;
                this.$refs.xTableResult1.setActiveCell(thisrow, "rpt_itemname");
              }
            }
          });
        });
      }
    },
    listsearch() {
      var val = this.listsearchkey;
      this.tableDataListS = this.tableDataList.filter(item => {
        return item.pat_name.toUpperCase().indexOf(val.toUpperCase()) > -1 || item.barcode.toUpperCase().indexOf(val.toUpperCase()) > -1;
      });
    },
    CombChange() {
      if (this.itemcombid) {
        this.$tool
          .request({
            url: "LIS/LIS3/LIS310",
            method: "post",
            data: {
              action: "querycombdetail",
              itemcombid: this.itemcombid,
            }
          }).then((res) => {
            if (res.data && res.data.length > 0) {
              console.log(res.data);
              this.itemcombdetail = res.data;
            }
          }).catch(() => { });
      } else {
        this.itemcombdetail = [];
      }
    },
    ResultMove(row, type, index, coltype) {
      if (type == 1) {
        if (index < this.$refs.xTableResult.tableFullData.length - 1) {
          var row = this.$refs.xTableResult.tableFullData[index + 1];
          this.$refs.xTableResult.setCurrentRow(row);
          if (coltype == "rpt_itemname") {
            this.linkshow = true;
            this.$refs.xTableResult.setActiveCell(row, "rpt_itemname");
          } else {
            this.$refs.xTableResult.setActiveCell(row, coltype);
          }
        }
      } else {
        if (index != 0) {
          var row = this.$refs.xTableResult.tableFullData[index - 1];
          this.$refs.xTableResult.setCurrentRow(row);
          if (coltype == "rpt_itemname") {
            this.linkshow = true;
            this.$refs.xTableResult.setActiveCell(row, "rpt_itemname");
          } else {
            this.$refs.xTableResult.setActiveCell(row, coltype);
          }
        }
      }
    },
    ListDblClick({ row, rowIndex, $rowIndex, column }) {
      if (column.property == "pat_name" && this.Options.doublefilterpatname > 0) {
        this.tableDataListS = this.tableDataList.filter(item => item.pat_name == row.pat_name);
      }
      if (column.property == "req_reason" && this.Options.doublefilterrs > 0) {
        this.tableDataListS = this.tableDataList.filter(item => item.req_reason == row.req_reason);
      }
      if (column.property == "specimen_code" && this.Options.doublefilterrs > 0) {
        this.tableDataListS = this.tableDataList.filter(item => item.specimen_code == row.specimen_code);
      }
    },
    activeMethod({ row, column }) {
      if (column.property == "rpt_itemname") {
        if (row.rptna_edit_active || this.Options.allowrptnaedit == "1") {
          return true;
        } else {
          return false;
        }
      } else {
        return true;
      }
    },
    ResultCellClick({ row, column }) {
      if (column.property == "rpt_itemname" && !row.rptna_edit_active && this.Options.allowrptnaedit != "1") {
        if (row.linkitemfalg == "1") {
          //加入延迟效果，区分双击与单机事件
          console.log(this.rptnaIsNotDouble);
          if (this.rptnaIsNotDouble) {
            this.rptnaIsNotDouble = false;
          } else {
            this.rptnaIsNotDouble = true;
          }
          this.timer = setTimeout(() => {  //设置延迟执行
            if (this.rptnaIsNotDouble) {
              this.linkitemcode = row.rpt_itemcode;
              this.dialogLinkRptVisible = true;
            }
            this.rptnaIsNotDouble = false;
          }, 300);
        }
        this.$refs.xTableResult.setActiveCell(row, 'result_str');
        return;
      }
      if (!this.editflag || row.alertrelease == "1") return;
    },
    ResultCellClick1({ row, column }) {
      if (column.property == "rpt_itemname" && !row.rptna_edit_active && this.Options.allowrptnaedit != "1") {
        if (row.linkitemfalg == "1") {
          //加入延迟效果，区分双击与单机事件
          console.log(this.rptnaIsNotDouble);
          if (this.rptnaIsNotDouble) {
            this.rptnaIsNotDouble = false;
          } else {
            this.rptnaIsNotDouble = true;
          }
          this.timer = setTimeout(() => {  //设置延迟执行
            if (this.rptnaIsNotDouble) {
              this.linkitemcode = row.rpt_itemcode;
              this.dialogLinkRptVisible = true;
            }
            this.rptnaIsNotDouble = false;
          }, 300);
        }
        this.$refs.xTableResult1.setActiveCell(row, 'result_str');
        return;
      }
      if (!this.editflag || row.alertrelease == "1") return;
    },
    handleEmptyDblclick() {
      console.log("Empty Dblclick");
      if (this.celldblclickflag) {
        this.celldblclickflag = false;
      } else {
        this.ResultAddAsync();
      }
    },
    DblEvent({ row, rowIndex, $rowIndex, column }) {
      this.celldblclickflag = true;
      if (!this.editflag || row.alertrelease == "1") return;
      switch (column.property) {
        case "rpt_itemname":
          this.dialogRptVisible = true;
          this.$nextTick(() => {
            this.$refs.rptdialog.$refs.qcodeinput.focus();
          });
          this.tempRptItem = row;
          break;
        case "result1":
          //this.QueryResultAll(row.rpt_itemcode, 0);
          this.dialogResultVisible = true;
          this.dialogResultItem = "result1";
          if (this.tableDataResultS.length > 0)
            this.$nextTick(() => {
              this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
            });
          break;
        case "result2":
          //this.QueryResultAll(row.rpt_itemcode, 0);
          this.dialogResultVisible = true;
          this.dialogResultItem = "result2";
          if (this.tableDataResultS.length > 0)
            this.$nextTick(() => {
              this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
            });
          break;
        case "result3":
          //this.QueryResultAll(row.rpt_itemcode, 0);
          this.dialogResultVisible = true;
          this.dialogResultItem = "result3";
          if (this.tableDataResultS.length > 0)
            this.$nextTick(() => {
              this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
            });
          break;
        case "result4":
          //this.QueryResultAll(row.rpt_itemcode, 0);
          this.dialogResultVisible = true;
          this.dialogResultItem = "result4";
          if (this.tableDataResultS.length > 0)
            this.$nextTick(() => {
              this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
            });
          break;
        case "cp_lastresult":
          this.QueryItemHistory(row.rpt_itemcode);
          break;
        case "redo_flag":
          var redo = "M";
          if (row.redo_flag == "1" || row.redo_flag == "M") redo = "2";
          else if (row.redo_flag == "2") redo = "N";
          else redo = "M";
          this.SaveNeedRechk(row, redo);
          break;
      }
    },
    //双击弹窗添加项目
    addrptitem(c, n, row) {
      var rename = "";
      switch (this.Options.itemshowmode) {
        case "1":
          rename = "[" + row.itemcode_en + "]";
          break;
        case "2":
          rename = n + " [" + row.itemcode_en + "]";
          break;
        case "3":
          rename = n;
          break;
        case "4":
          rename = "[" + row.itemcode_en + "] " + n;
          break;
        case "5":
          rename = c;
          break;
        default:
          rename = "[" + row.itemcode_en + "] " + n;
          break;
      }

      var currentrow = this.$refs.xTableResult.getCurrentRow();
      var rowindex = this.$refs.xTableResult.getRowIndex(currentrow);
      if (this.Options.doubleresultcol == 1) {
        currentrow = this.$refs.xTableResult1.getCurrentRow();
        rowindex = this.$refs.xTableResult1.getRowIndex(currentrow);
      }

      var hasrow = this.$refs.xTableResult.tableFullData.find(item => item.rpt_itemcode == c);
      if (!hasrow && this.Options.doubleresultcol == 1) {
        hasrow = this.$refs.xTableResult1.tableFullData.find(item => item.rpt_itemcode == c);
      }
      if ((hasrow) && currentrow.rpt_itemcode != c) {
        this.$confirm("不能选择重复的项目", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          focusCancelButton: false,
          type: "warning"
        })
          .then(() => {
            this.tempRptItem.rpt_itemname = "";
            this.linkshow = true;
            if (this.Options.doubleresultcol == 1) {
              this.$refs.xTableResult1.setActiveCell(currentrow, "rpt_itemname").then(() => {
                if (this.$refs.rptitemname) {
                  this.$nextTick(() => {
                    this.$refs.rptitemname[0].focus();
                  })

                }
              });
            } else {
              this.$refs.xTableResult.setActiveCell(currentrow, "rpt_itemname").then(() => {
                if (this.$refs.rptitemname) {
                  this.$refs.rptitemname[0].focus();
                }
              });
            }

          })
          .catch(() => {
            this.tempRptItem.rpt_itemname = "";
            this.linkshow = true;
            if (this.Options.doubleresultcol == 1) {
              this.$refs.xTableResult1.setActiveCell(currentrow, "rpt_itemname").then(() => {
                if (this.$refs.rptitemname) {
                  this.$refs.rptitemname[0].focus();
                }
              });
            } else {
              this.$refs.xTableResult.setActiveCell(currentrow, "rpt_itemname").then(() => {
                if (this.$refs.rptitemname) {
                  this.$refs.rptitemname[0].focus();
                }
              });
            }
            // this.$refs.xTableResult.setActiveCell(currentrow, "rpt_itemname").then(() => {
            //     if (this.$refs.rptitemname) {
            //         this.$refs.rptitemname.focus();
            //     }
            // });
          });
      } else {
        // for (var pKey in this.tempRptItem) {
        //     if (pKey == "rpt_itemname") {
        //         this.tempRptItem.rpt_itemname = rename;
        //     } else if (row.hasOwnProperty(pKey)) {
        //         if (this.tempRptItem[pKey] != row[pKey]) {
        //             this.tempRptItem[pKey] = row[pKey];
        //         }
        //     }
        // }
        this.tempRptItem.rpt_itemcode = c;
        this.tempRptItem.rpt_itemname = rename;
        this.tempRptItem.rptna_edit_active = false;
        this.tempRptItem.result_unit = row.unit;
        this.tempRptItem.result_ref = row.ref_text;
        this.tempRptItem.germflag = row.germflagid;
        this.tempRptItem.testmethod = row.testmethod;
        this.tempRptItem.hr_flag = row.hr_flag;
        this.tempRptItem.itemcode_en = row.itemcode_en;
        if (row.defaultval) {
          this.tempRptItem.result_str = row.defaultval;
        }
        if (row.defaultresult1) {
          this.tempRptItem.result1 = row.defaultresult1;
        }
        if (row.defaultresult2) {
          this.tempRptItem.result2 = row.defaultresult2;
        }
        if (row.defaultresult3) {
          this.tempRptItem.result3 = row.defaultresult3;
        }
        this.tempRptItem.keyitem = row.keyitem;
        if (this.dialogRptVisible) {
          this.$nextTick(() => {
            if (this.Options.doubleresultcol == 1) {
              this.$refs.xTableResult1.setActiveCell(currentrow, "result_str");
            } else {
              this.$refs.xTableResult.setActiveCell(currentrow, "result_str");
            }
          });
        }
      }
      this.dialogRptVisible = false;
    },
    SelectRptItems(rows) {
      var indexdata = this.$refs.xTableResult.tableFullData.filter(item => item.rpt_itemcode == "" || item.rpt_itemcode == null);
      var indexs = [];
      //先把当前左侧结果项目为空的全部塞进indexs
      for (let j = 0; j < indexdata.length; j++) {
        indexs.push(this.$refs.xTableResult.tableFullData.indexOf(indexdata[j]));
      }
      var indexdata1 = [];
      var indexs1 = [];
      //再把当前右侧结果项目为空的全部塞进indexs1
      if (this.Options.doubleresultcol == 1) {
        indexdata1 = this.$refs.xTableResult1.tableFullData.filter(item => item.rpt_itemcode == "" || item.rpt_itemcode == null);
        for (let j1 = 0; j1 < indexdata1.length; j1++) {
          indexs1.push(this.$refs.xTableResult1.tableFullData.indexOf(indexdata1[j1]));
        }

      }
      for (let i = 0; i < rows.length; i++) {
        let row = rows[i];
        //左侧列表有这个项目了，跳过，不管这个项目
        var hasrow = this.$refs.xTableResult.tableFullData.find(item => item.rpt_itemcode == row.rpt_itemcode);
        if (hasrow) {
          continue;
        }
        //右侧列表有这个项目了，跳过，不管这个项目
        if (this.Options.doubleresultcol == 1) {
          var hasrow1 = this.$refs.xTableResult1.tableFullData.find(item => item.rpt_itemcode == row.rpt_itemcode);
          if (hasrow1) {
            continue;
          }
        }

        var rename = "";
        //根据选项来决定最终显示项目名称
        switch (this.Options.itemshowmode) {
          case "1":
            rename = "[" + row.itemcode_en + "]";
            break;
          case "2":
            rename = row.rpt_itemname + " [" + row.itemcode_en + "]";
            break;
          case "3":
            rename = row.rpt_itemname;
            break;
          case "4":
            rename = "[" + row.itemcode_en + "] " + row.rpt_itemname;
            break;
          case "5":
            rename = row.rpt_itemcode;
            break;
          default:
            rename = "[" + row.itemcode_en + "] " + row.rpt_itemname;
            break;
        }
        var insertrow = { rpt_itemname: rename, rpt_itemcode: row.rpt_itemcode, result_unit: row.unit, result_ref: row.ref_text, germflag: row.germflagid, testmethod: row.testmethod, hr_flag: row.hr_flag, itemcode_en: row.itemcode_en, rptunitid: this.myrptunitid, reportid: this.PatientInfo.reportid, result_str: row.old_result_str ? row.old_result_str : "", keyitem: row.keyitem, rptna_edit_active: false };
        //双列模式下，统统往右侧加，不管双列每列显示行数
        if (this.Options.doubleresultcol == 1) {
          if (i < indexs1.length) {
            for (var item in insertrow) {
              this.$refs.xTableResult1.tableFullData[indexs1[i]][item] = insertrow[item];
            }
          } else {
            this.$refs.xTableResult1.insertAt(insertrow, -1);
          }
        } else {
          if (i < indexs.length) {
            for (var item in insertrow) {
              this.$refs.xTableResult.tableFullData[indexs[i]][item] = insertrow[item];
            }
          } else {
            this.$refs.xTableResult.insertAt(insertrow, -1);
          }
        }

        // if(i == 0)
        // {
        //     this.tempRptItem.rpt_itemcode = row.rpt_itemcode;
        //     this.tempRptItem.rpt_itemname = rename;
        //     this.tempRptItem.result_unit = row.unit;
        //     this.tempRptItem.result_ref = row.ref_text;
        //     this.tempRptItem.germflag = row.germflagid;
        //     this.tempRptItem.testmethod = row.testmethod;
        //     this.tempRptItem.itemcode_en = row.itemcode_en;
        // }
        // else
        // {

        // }
      }
      var currentrow = this.$refs.xTableResult.getCurrentRow();
      if (this.Options.doubleresultcol == 1) {
        currentrow = this.$refs.xTableResult1.getCurrentRow();
      }
      if (this.dialogRptVisible) {
        this.$nextTick(() => {
          if (this.Options.doubleresultcol == 1) {
            this.$refs.xTableResult1.setActiveCell(currentrow, "result_str");
          } else {
            this.$refs.xTableResult.setActiveCell(currentrow, "result_str");
          }

        });
      }
      this.dialogRptVisible = false;
    },
    CenterDblClick(e) {
      this.ResultAddAsync();
    },
    RefreshOptions(p, checkmode) {
      this.Options = p;
      //this.tableResultColumn = this.Options.rCols;
      this.RefreshColumns(this.tableResultColumn, checkmode ? checkmode : false);
    },

    RefreshColumns(column, checkmode) {
      this.tableResultColumn = XE.clone(this.Options.rCols, true);
      column = this.tableResultColumn;
      if (checkmode) {
        var lastindex = column.findIndex(item => item.field == "cp_lastresult");
        for (let i = 5; i > 0; i--) {
          //if (i < 5) lastindex = column.findIndex(item => item.field == "cp_lastresult" + i);
          var row = { field: "cp_lastresult" + (i - 1), title: this.Options.refresultmixreport == "1" ? "上" + i + "次结果" : "历史结果" + i, width: "80px" };
          if (i == 1) {
            lastindex = column.findIndex(item => item.field == "cp_lastresult");
            // row = { field: "cp_lastresult", title: this.Options.refresultmixreport == "1" ? "上" + i + "次结果" : "历史结果" + i, width: "80px" };
            column[i].title = this.Options.refresultmixreport == "1" ? "上" + i + "次结果" : "历史结果" + i;
          } else {
            column.splice(lastindex, 0, row);
          }
        }
      }
      let colnamestr = "_undefined"; //兼容以前保存的本地设置，前面的index列，在vxe-table里面之前取的_undefined
      this.tableResultColumn.forEach(function (item) {
        colnamestr += "_" + item.field;
      });
      colnamestr = this.$tool.MD5(colnamestr);
      let _this = this;
      this.$nextTick(() => {
        _this.tableid = colnamestr; // this.myrptunitid.toString();
        if (this.Options.doubleresultcol > 0) {
          _this.tableid1 = colnamestr; // this.myrptunitid.toString();
        }
      });
    },
    ClearTableDate() {
      return new Promise((s, f) => {
        this.tableDataResult = [];
        this.editflag = true;
        s();
      });
    },
    QueryResult(rptinfo) {
      return Promise((s, f) => {
        this.Refreshflag = true;
        let reportid = rptinfo.reportid;
        if (rptinfo.rechkflag == "9" || (this.Options.onlymodifymyreport == "1" && $tool.getSession(this.$tool.loginuserno) != rptinfo["report_user"]) || (rptinfo.barcode && rptinfo.barcode.indexOf("-退") > -1)) {
          this.editflag = false;
        } else {
          this.editflag = true;
        }
        let logcontent = "";
        logcontent += XE.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss.S") + " :开始查询报告: " + reportid + "\r\n";
        //this.$pub.Log("开始查询报告:" + reportid);
        if (this.showtabid == 2) {
          if (reportid) {
            this.queryreportview(reportid);
          } else {
            this.queryreportview("no");
          }
        }
        //每个报告都做一下，防止勾选了本组报告单元，获取显示PDF报告选项放到后台去
        if (reportid) {
          this.queryreportpdf(reportid);
        } else {
          this.queryreportpdf("no");
        }

        this.$tool
          .request({
            url: "LIS/LIS3/LIS310",
            method: "post",
            data: {
              action: "queryresultlist",
              reportid: reportid,
              rptunitid: rptinfo.rptunitid,
              sampleno: rptinfo.sampleno,
              sampledate: rptinfo.sampledate,
              checkmode: this.Checkmode ? "1" : "0"
            }
          })
          .then(res => {
            this.tableDataResult = [];
            logcontent += XE.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss.S") + " :result开始查询报告结束: " + reportid + "\r\n";
            //this.$pub.Log("result开始查询报告结束:" + reportid);
            console.log("resultdata", res.vxtab.Data);
            if (res.vxtab.Data.length > 0) {
              this.dealCompResultstr(res.vxtab.Data);
            }
            if (this.Checkmode && res.vxtab.Data.length > 0 && res.rptinfo && res.rptinfo.hasOwnProperty("reportid") && res.rptinfo.reportid && res.rptinfo.hasOwnProperty("pat_no") && res.rptinfo.pat_no) {
              let havehistoryresultdata = this.AppendHistoryData(res.vxtab.Data, res.redt);
              if (this.Options.doubleresultcol == 1) {
                this.tableDataResult = [];
                this.tableDataResult1 = [];
                var cnt = this.Options.doubleresultrows;
                for (let index = 0; index < havehistoryresultdata.length; index++) {
                  const element = havehistoryresultdata[index];
                  if (index < cnt) {
                    this.tableDataResult.push(element);
                  }
                  else {
                    this.tableDataResult1.push(element);
                  }
                }
              }
              else {
                this.tableDataResult = havehistoryresultdata;
              }
            }
            else {
              //this.dealCompResultstr(res.vxtab.Data);
              // 拆分table
              if (this.Options.doubleresultcol == 1) {
                this.tableDataResult = [];
                this.tableDataResult1 = [];
                var cnt = this.Options.doubleresultrows;
                for (let index = 0; index < res.vxtab.Data.length; index++) {
                  const element = res.vxtab.Data[index];
                  if (index < cnt) {
                    this.tableDataResult.push(element);
                  }
                  else {
                    this.tableDataResult1.push(element);
                  }
                }
              }
              else {
                this.tableDataResult = res.vxtab.Data;
              }
            }

            this.noupdateflag = true;
            this.tableDataResultOld = [];
            //this.$refs.xTableResult.clearActived();
            //rptinfo.redo_flag = res.redo_flag;
            //rptinfo.alter_flag = res.alter_flag;
            this.loadingResult = false;
            this.Refreshflag = false;
            var lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult");
            if (lasttitle) {
              //如果有值就显示，没有就用默认历史结果
              if (res.historytitle) lasttitle.title = res.historytitle;
              else lasttitle.title = "历史结果";
            }
            //this.tableResultColumn.filter(item => item.field == "cp_lastresult")[0].title = res.historytitle;
            //end
            if (res.rptinfo != null) res.rptinfo.specialtype = res.specialtype;
            var returndata = { res: res.rptinfo, redo: res.redo, history: res.history, sampleno: res.sampleno };
            //不在前台做待审核状态判断了
            // var renum = 1;
            // if (res.vxtab.Data && res.vxtab.Data.length > 0) {
            //     if(this.Options.reservenullresult == "2"){
            //         renum = this.tableDataResult.filter(item => item.result_str == "未做" || item.result_str == "已上机" || item.result_str == "pending").length;
            //     }else{
            //         renum = this.tableDataResult.filter(item => !item.result_str || item.result_str == "" || item.result_str == "未做" || item.result_str == "已上机" || item.result_str == "pending").length;
            //     }
            // }
            this.$emit("PatChange", res.rptinfo, res.prechkflag, "");
            logcontent += XE.toDateString(new Date(), "yyyy-MM-dd HH:mm:ss.S") + " :result开始查询报告赋值结束: " + reportid + "\r\n";
            this.$pub.Log(logcontent);
            s(returndata);
          })
          .catch(error => {
            this.$message.error("错误:" + error);
            this.Refreshflag = false;
            f();
          });
      });
    },

    //后台调用计算参考值
    CalcRef(row) {
      this.$tool
        .request({
          url: "LIS/LIS3/LIS310",
          method: "post",
          data: {
            action: "calcref",
            sex: this.PatientInfo.pat_sex,
            ageyear: this.PatientInfo.pat_birth ? this.PatientInfo.pat_birth : this.PatientInfo.pat_agestr,
            specimen: this.PatientInfo.specimen_code,
            physicycle: this.PatientInfo.physicycle,
            deptno: this.PatientInfo.req_deptno,
            diagicd: this.PatientInfo.pat_diag_icd,
            sampledate: this.PatientInfo.sampledate,
            rptunitid: this.PatientInfo.rptunitid,
            sampleno: this.PatientInfo.sampleno,
            hospcode: this.PatientInfo.hospcode,
            resultrow: row
          }
        })
        .then(res => {
          for (var item in res) {
            row[item] = res[item];
          }
        })
        .catch(error => {
          this.$message.error("错误:" + error);
        });
    },
    QueryResultAll(rptitemcode, rekind) {
      this.$tool
        .request({
          url: "LIS/LIS3/LIS310",
          method: "post",
          data: {
            action: "getrptitemval",
            rpt_itemcode: rptitemcode,
            resultkind: rekind,
            rptunitid: this.myrptunitid
          }
        })
        .then(res => {
          this.tableColumnResultAll = res.Cols;
          this.tableDataResultAll = res.Data;
          this.tableDataResultS = res.Data;
          if (this.tableDataResultAll.length > 0 && this.Options.showrptitemvalbyfocus == "2") {
            this.textvalueshow = true;
          }
        });
    },
    QueryItemHistory(rptitemcode) {
      this.$tool
        .request({
          url: "LIS/LIS3/LIS310",
          method: "post",
          data: {
            action: "queryitemhistoryresult",
            rptitemcode: rptitemcode,
            reportid: this.PatientInfo.reportid,
            rptunitid: this.myrptunitid
          }
        })
        .then(res => {
          if (res) {
            this.tableItemHData = res;
            for (let i = 0; i < this.tableItemHData.length; i++) {
              this.tableItemHData[i].sampledate = XE.toDateString(this.tableItemHData[i].sampledate, "yyyy-MM-dd");
            }
            this.dialogItemhistoryVisible = true;
          }
        });
    },
    LinkItemCancel() {
      this.dialogLinkRptVisible = false;
    },
    //病历号改变的逻辑

    //Result弹出框的各项方法
    ResultSearchInput(value) { },
    ResultSearchkeydown() {
      this.tableDataResultS = this.tableDataResultAll.filter(item => item.textvalue.toUpperCase().indexOf(this.Resultqcode.toUpperCase()) > -1 || item.inputcode.toUpperCase().indexOf(this.Resultqcode.toUpperCase()) > -1 || (item.seq + "").indexOf(this.Resultqcode.toUpperCase()) > -1);
    },
    Resultok() {
      var row = this.$refs.xTableResultAll.getCurrentRow();
      if (row) {
        //区分单双列模式
        let resultdata = [];
        if (this.Options.doubleresultcol > 0) {
          //双列
          resultdata = XE.union(this.$refs.xTableResult.tableFullData, this.$refs.xTableResult1.tableFullData);
        } else {
          //单列
          resultdata = this.$refs.xTableResult.tableFullData;
        }
        var uprow = resultdata.filter(item => item.rpt_itemcode == row.rpt_itemcode)[0];
        if (this.dialogResultItem == "result_str") {
          uprow.result_flag = row.result_flag;
          uprow.redoflag = row.redoflag;
          uprow.limitflag = row.limitflag;
        }
        uprow[this.dialogResultItem] = row.textvalue;
        if (this.Options.realcalcsoc == "1" && this.Options.showresult1 == "1" && this.Options.showresult2 == "1" && this.Options.showresult3 == "1") {
          if (this.dialogResultItem == "result1" || this.dialogResultItem == "result3") {
            if (!isNaN(parseFloat(uprow.result1)) && !isNaN(parseFloat(uprow.result3)) && parseFloat(uprow.result3) > 0) {
              var digit = parseInt(this.Options.realcalcsocdecimal);
              var result2 = (parseFloat(uprow.result1) / parseFloat(uprow.result3)).toFixed(digit);
              uprow.result2 = result2;
            }
          }
        }
        this.CalcRef(uprow);
        this.dialogResultVisible = false;
        this.dialogResultItem = "";
      } else {
        this.$message("未选中报告结果!");
      }
    },
    Resultcancel() {
      this.dialogResultVisible = false;
      this.dialogResultItem = "";
    },
    ResultSelect({ row }) {
      var uprow = this.$refs.xTableResult.tableFullData.filter(item => item.rpt_itemcode == row.rpt_itemcode)[0];
      if (this.dialogResultItem == "result_str") {
        uprow.result_flag = row.result_flag;
        uprow.redoflag = row.redoflag;
        uprow.limitflag = row.limitflag;
      }
      uprow[this.dialogResultItem] = row.textvalue;
      if (this.Options.realcalcsoc == "1" && this.Options.showresult1 == "1" && this.Options.showresult2 == "1" && this.Options.showresult3 == "1") {
        if (this.dialogResultItem == "result1" || this.dialogResultItem == "result3") {
          if (!isNaN(parseFloat(uprow.result1)) && !isNaN(parseFloat(uprow.result3)) && parseFloat(uprow.result3) > 0) {
            var digit = parseInt(this.Options.realcalcsocdecimal);
            var result2 = (parseFloat(uprow.result1) / parseFloat(uprow.result3)).toFixed(digit);
            uprow.result2 = result2;
          }
        }
      }
      this.CalcRef(uprow);
      this.dialogResultVisible = false;
      this.dialogResultItem = "";
    },
    AdviceClick({ row }) {
      console.log("row", row);
      if (this.ResultTxt) {
        if (this.appendChangeRow) {
          this.ResultTxt += "\n" + row.textvalue;
        } else {
          if (this.ResultTxt) {
            this.ResultTxt += "," + row.textvalue;
          } else {
            this.ResultTxt += row.textvalue;
          }
        }
      } else {
        this.ResultTxt = row.textvalue;
      }
    },
    AdvicedblClick({ row }) {
      this.ResultTxt = row.textvalue;
    },
    AdviceSubmit() {
      this.tempRptItem.result_txt = this.ResultTxt;
      this.dialogResultTxtVisible = false;
    },
    SpaceEvent(type) {
      var val = this.PatientInfo[type + "name"];
      if (!val.replace(/\s*/g, "")) {
        this.inputdblEvent(type);
      }
    },

    //危急值上报弹窗
    CheckDangerDeal(type) {
      var alertinfo = {
        chksendhis: this.sendbyhis ? "1" : "0",
        chkphone: this.noticebyphone ? "1" : "0",
        chkmessage: this.noticebymsg ? "1" : "0",
        chkrepeat: this.retelled ? "1" : "0",
        chkmsguser: this.msgtodutyman ? "1" : "0",
        chkmsggrdept: this.noticeinfec ? "1" : "0",
        alertuser: this.ExaminreportMan,
        rectelman: this.noticeddoctor,
        shortmsgtelnum: this.noticeddoctorno,
        memo: this.remarks
      };
      this.CheckReportRequest(this.InputMsg, type, alertinfo);
    },
    selectchange(item, row) {
      // console.log("111",val);
      row.result_str = item.textvalue;
      row.result_flag = item.result_flag;
      this.$refs.xTableResult.clearActived();
    },
    querySearch(str, cb) {
      var results = this.tableDataResultAll;
      // 调用 callback 返回建议列表的数据
      // 报告单元选项不显示文字结果
      if (this.Options.showrptitemvalbyfocus != "1") {
        results = [];
      }
      cb(results);
    },
    CancelDel() {
      // var removerecord = this.$refs.xTableResult.getRemoveRecords();
      // var removeinsertdata = [];
      // for (let i = 0; i < removerecord.length; i++) {
      //     if (!this.$refs.xTableResult.tableFullData.find(item => item.rpt_itemcode == removerecord[i].rpt_itemcode)) {
      //         alert(JSON.stringify(removerecord[i]));
      //         removeinsertdata.push(removerecord[i]);
      //     }
      // }
      // this.tableDelData = removeinsertdata;
      this.$tool
        .request({
          url: "LIS/LIS3/LIS310",
          method: "post",
          data: {
            action: "querydeldata",
            reportid: this.PatientInfo.reportid
          }
        })
        .then(res => {
          this.tableDelData = res.data;
        });

      this.dialogDelVisible = true;
    },
    async SubmitCancelDel() {
      this.ddlData = await this.$ddldata.getrptunititem(this.myrptunitid);
      var removerecord = this.$refs.xTableDel.getSelectRecords();
      var addrptitems = [];
      if (removerecord && removerecord.length > 0) {
        for (let i = 0; i < removerecord.length; i++) {
          var select = this.ddlData.filter(item => item.rpt_itemcode.toUpperCase() == removerecord[i].rpt_itemcode);
          if (select && select.length > 0) {
            console.log("select[0]:" + JSON.stringify(select[0]));
            var addrow = { itemcode_en: select[0].itemcode_en, rpt_itemname: select[0].rpt_itemname, rpt_itemcode: select[0].rpt_itemcode, unit: select[0].unit, ref_text: select[0].ref_text, germflagid: select[0].germflagid, testmethod: select[0].testmethod, hr_flag: select[0].hr_flag, keyitem: select[0].keyitem, old_result_str: removerecord[i].result_str };
            console.log("addrow:" + JSON.stringify(addrow));
            addrptitems.push(addrow);
          }
          // if (!this.$refs.xTableResult.tableFullData.find(item => item.rpt_itemcode == removerecord[i].rpt_itemcode)) {
          //     //this.$refs.xTableResult.insertAt(removerecord[i], -1);
          //     item.result_str = removerecord[i].oldvalue;
          //     this.SelectRptItems(item);
          // }
        }
      }
      if (addrptitems.length > 0) {
        this.SelectRptItems(addrptitems);
      }
      this.dialogDelVisible = false;
    },
    handleIconClick() {
      this.textvalueshow = !this.textvalueshow;
      // if (this.iconclass == "el-icon-arrow-down") {
      //     this.iconclass = "el-icon-arrow-up";
      //     this.textvalueshow = true;
      // } else {
      //     this.iconclass = "el-icon-arrow-down";
      //     this.textvalueshow = false;
      // }
    },
    ResultDblClick() {
      //this.QueryResultAll(row.rpt_itemcode, 0);
      this.textvalueshow = false;
      this.dialogResultVisible = true;
      this.dialogResultItem = "result_str";
      if (this.tableDataResultS.length > 0) {
        this.$nextTick(() => {
          this.$refs.xTableResultAll.setCurrentRow(this.$refs.xTableResultAll.getData(0));
        });
      }
    },
    ResultTextClick({ row }, rptrow) {
      rptrow.result_str = row.textvalue;
      rptrow.result_flag = row.result_flag;
      this.textvalueshow = false;
    },
    //处理对照项目结果
    dealCompResultstr(data) {
      for (let i = 0; i < data.length; i++) {
        var item = data[i];
        var comp_itemcode = data[i].comp_itemcode;
        var comps = data.filter(item => item.rpt_itemcode == comp_itemcode);
        if (comps.length > 0) {
          data[i].result_str1 = comps[0].result_str;
        }
      }
    },

    //添加历史结果
    AppendHistoryData(redt, redtall) {
      var dt = redt;

      for (let i = 0; i < dt.length; i++) {
        dt[i].cp_lastresult1 = redtall[i].cp_lastresult1;
        dt[i].cp_lastresultflag1 = redtall[i].cp_lastresultflag1;
        dt[i].cp_lastresult2 = redtall[i].cp_lastresult2;
        dt[i].cp_lastresultflag2 = redtall[i].cp_lastresultflag2;
        dt[i].cp_lastresult3 = redtall[i].cp_lastresult3;
        dt[i].cp_lastresultflag3 = redtall[i].cp_lastresultflag3;
        dt[i].cp_lastresult4 = redtall[i].cp_lastresult4;
        dt[i].cp_lastresultflag4 = redtall[i].cp_lastresultflag4;
      }
      if (this.Options.refresultmixreport != "1") {
        var one = redtall.find(item => item.cp_lastresultdays != "");
        var tow = redtall.find(item => item.cp_lastresultdays1 != "");
        var three = redtall.find(item => item.cp_lastresultdays2 != "");
        var four = redtall.find(item => item.cp_lastresultdays3 != "");
        var five = redtall.find(item => item.cp_lastresultdays4 != "");
        var lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult");
        if (one && lasttitle) lasttitle.title = one.cp_lastresultdays;
        else lasttitle.title = "历史结果";
        lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult1");
        if (tow && lasttitle) lasttitle.title = tow.cp_lastresultdays1;
        else lasttitle.title = "历史结果1";
        lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult2");
        if (three && lasttitle) lasttitle.title = three.cp_lastresultdays2;
        else lasttitle.title = "历史结果2";
        lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult3");
        if (four && lasttitle) lasttitle.title = four.cp_lastresultdays3;
        else lasttitle.title = "历史结果3";
        lasttitle = this.tableResultColumn.find(item => item.field == "cp_lastresult4");
        if (five && lasttitle) lasttitle.title = five.cp_lastresultdays4;
        else lasttitle.title = "历史结果4";
      }

      return dt;
    },
    //结果改变判断事件
    StrChange(row) {
      if (this.Options.modifyresultmsg == "2") {
        if (this.noupdateflag) {
          var result = this.$refs.xTableResult.getUpdateRecords();
          if (result.length == 0) return;
          var index = result.find(item => item.odata.rpt_itemcode == row.rpt_itemcode);
          if (index) {
            this.$confirm("是否修改当前项目结果", "提示", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              focusCancelButton: false,
              type: "warning"
            })
              .then(() => {
                this.noupdateflag = false;
                this.CalcRef(row);
              })
              .catch(() => {
                this.noupdateflag = false;
                row.result_str = index.odata.result_str;
              });
          }
        }
      } else if (this.Options.modifyresultmsg == "3") {
        var result = this.$refs.xTableResult.getUpdateRecords();
        if (result.length == 0) return;
        var index = result.find(item => item.odata.rpt_itemcode == row.rpt_itemcode);
        if (index) {
          var olditem = this.tableDataResultOld.find(item => item.rpt_itemcode == row.rpt_itemcode);
          this.$confirm("是否修改当前项目结果", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            focusCancelButton: false,
            type: "warning"
          })
            .then(() => {
              this.CalcRef(row);
              if (olditem) olditem.value = row.result_str;
              else this.tableDataResultOld.push({ rpt_itemcode: row.rpt_itemcode, value: row.result_str });
            })
            .catch(() => {
              if (olditem) row.result_str = olditem.value;
              else row.result_str = index.odata.result_str;
            });
        }
      } else {
        this.CalcRef(row);
      }
    },
    //点击行复查标志执行修改复查标志
    SaveNeedRechk(row, redoflag) {
      var result = [];
      var nowflag = row.redo_flag;
      row.redo_flag = redoflag;
      row.instrid = "";
      result.push(row);
      this.$tool
        .request({
          url: "LIS/LIS3/LIS310",
          method: "post",
          data: {
            action: "saveredoflag",
            reportid: this.PatientInfo.reportid,
            tablestr: result
          }
        })
        .then(res => {
          if (res.flag == "1") {
            var indec = this.tableDataResult.findIndex(item => item.rpt_itemcode == row.rpt_itemcode);
            if (indec > -1) this.tableDataResult[indec].redo_flag = redoflag;
            //this.$refs.xTableResult.loadData(this.tableDataResult);
            this.PatientInfo.redo_flag = res.redo_flag;
            this.$emit("PatChange", this.PatientInfo, "", "redo");
          } else {
            this.$alert(res.msg, "错误");
            row.redo_flag = nowflag;
          }
        });
    }
  },
  watch: {
    rptunitid(val) {
      this.myrptunitid = val;
      this.showtabid = 1;
    },
    textvalueshow(val) {
      if (val) {
        this.iconclass = "el-icon-arrow-up";
      } else {
        this.iconclass = "el-icon-arrow-down";
      }
    },
    dialogLinkRptVisible(val) {
      if (!val) {
        let currentrow = this.$refs.xTableResult.getCurrentRow();
        this.linkshow = true;
        this.$refs.xTableResult.setActiveCell(currentrow, "rpt_itemname");
      }
    }
  }
};
</script>

<style scoped>

::v-deep .disabled-cell {
  background-color: #f7f7f7;
}

::v-deep .warn-high {
  background-color: #ffc0c0;
}

::v-deep .warn-low {
  background-color: #c0c0ff;
}

::v-deep .danger {
  background-color: #ff0000;
}

::v-deep .unprint {
  color: #ea66a6;
}

::v-deep .paddingcolumn {
  padding: 0 3px;
}

::v-deep .fontbold {
  font-weight: bold;
}

::v-deep .el-image {
  z-index: 2007;
}

::v-deep .vxe-body--row .el-input--small .el-input__inner {
  height: 18px !important;
  line-height: 18px !important;
}

::v-deep .middle-left .el-checkbox__input.is-checked+.el-checkbox__label {
  color: red;
}

::v-deep .dialogdanger .el-textarea.is-disabled .el-textarea__inner {
  color: red;
}

::v-deep .el-input--small .el-input__icon {
  line-height: 18px !important;
}

.menu_style {
  position: absolute;
  width: 150px;
  background-color: #fff;
  border-radius: 2px;
  box-shadow: 2px 2px 14px #d0d0d0;
  z-index: 2008;
}

.menu_style>ul>li {
  text-indent: 25px;
  height: 38px;
  line-height: 38px;
  border-bottom: 1px dashed #f0f0f0;
  cursor: pointer;
}

.menu_style>ul>li:hover {
  background: #e0eeff;
}

.dangerPatInfo tr td:nth-child(even) {
  width: 40px;
  border-bottom: 1px solid black;
}

table tr td:nth-child(odd) {
  text-align: right;
  white-space: nowrap;
}

table tr td:nth-child(even) {
  text-align: left;
}

table tr td:nth-child(1) {
  width: 80px;
}

.reqitem-dialog {
  position: absolute;
  z-index: 10000;
}

::v-deep .ResultTable.vxe-table .vxe-cell {
  padding: 0;
  line-height: 18px;
}

::v-deep .paddingcolumn .vxe-cell {
  padding: 0 3px;
}

.el_main {
  padding: 0 0;
}

::v-deep .ResultTable .vxe-table--body td {
  height: 18px !important;
}

::v-deep .txtClass .el-textarea__inner {
  padding: 0;
}

::v-deep .ResultTxtTable.vxe-table .vxe-body--row td {
  background-color: #fff !important;
}

::v-deep .ResultTxtTable.vxe-table .vxe-body--row.row--hover td {
  background-color: #d7f1fd !important;
}

::v-deep .parent-row .vxe-cell {
  width: 100% !important;
}

</style>
